package com.yxch.admin.controller.home;

import com.yxch.admin.model.commen.Function;
import com.yxch.admin.model.home.CourseIntro;
import com.yxch.admin.model.home.TeacherTeam;
import com.yxch.admin.service.home.HomeService;
import com.yxch.admin.utils.ResultAPI;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/yxch/admin/home")
public class HomeController {
    @Autowired
    private HomeService homeService;

    /**
     * 获取游戏策划的课程介绍（富文本）
     *
     * @param courseId
     * @return
     */
    @GetMapping("/courseintro")
    public ResultAPI getCourseIntro(@RequestParam Integer courseId) {
        return homeService.getCourseIntro(courseId);
    }

    /**
     * 修改课程介绍
     *
     * @param courseIntro
     * @return
     */
    @PatchMapping("/courseintro")
    public ResultAPI updateCourseIntro(@RequestBody CourseIntro courseIntro) {
        return homeService.updateCourseIntro(courseIntro);
    }


    /**
     * 获取试题知识点
     *
     * @return
     */
    @GetMapping("/qspoint")
    public ResultAPI getQspoint(@RequestParam(required = false) Integer direction_id) {
        return homeService.getQspoint(direction_id);
    }

    /**
     * 获取首页功能以及介绍
     *
     * @return
     */
    @GetMapping("/function")
    public ResultAPI getFunction() {
        return homeService.getFunction();
    }

    @PostMapping("/function")
    public ResultAPI addandUpdateFunction(@RequestBody Function function) {
        return homeService.addandUpdateFunction(function);
    }

    @DeleteMapping("/function/{ids}")
    public ResultAPI deleteFunction(@PathVariable List<Integer> ids) {
        return homeService.deleteFunction(ids);
    }

    /**
     * 获取管理端首页top里的各data数量
     *
     * @return
     */
    @GetMapping("data")
    public ResultAPI getBaseData() {
        return homeService.getHomeBaseData();
    }

    /**
     * 获取近7日登录人数以及评论数
     *
     * @return
     */
    @GetMapping("days")
    public ResultAPI getDaysData() {
        return homeService.getDaysData();
    }

    /**
     * 获取饼状图：师生比例以及性别比例
     *
     * @return
     */
    @GetMapping("bing")
    public ResultAPI getBingData() {
        return homeService.getBingData();
    }

    /**
     * 获取知识点对应多少试题
     *
     * @return
     */
    @GetMapping("point")
    public ResultAPI getPointData() {
        return homeService.getPointData();
    }
}
